package textrpg.player.skills;

import textrpg.Loader;
import textrpg.items.Item;
import textrpg.items.resources.Ore;
import textrpg.items.tools.Pickaxe;
import textrpg.player.inventory.Inventory;

public class Mining {

    private int skillLevel = 100;
    private long thisRandom;
    private double mineMinRange;
    private long currentXP = 14391160;
    private Item item;
    private Ore ore;
    private Pickaxe pick;
    Inventory invent = new Inventory();

    public Mining() {
    }

    public void mineRock(int oreItemID, int pickaxeItemID) {
        if (!invent.isInventoryFull()) {
            ore = (Ore) item.itemList.get(oreItemID);
            pick = (Pickaxe) item.itemList.get(pickaxeItemID);

            mineMinRange = Math.floor(ore.getAverageTime() - ((skillLevel * 10) + (pick.getPickaxeLevel() * 333.33)) * ore.getDifficulty());
            System.out.println(mineMinRange);
            thisRandom = (long) (Math.random() * (ore.getAverageTime() / ((skillLevel * 0.01) + 1)) + mineMinRange);
            System.out.println(thisRandom);
            Loader.console = "You swing your " + pick.getItemName() + " at the rock.\n";
            Loader.console += ("Seconds taken to mine: " + (thisRandom / 1000)) + "\n";
            Loader.console += ("You manage to mine a piece of " + ore.getItemName() + "!") + "\n";
            Loader.console += ("You recieve " + ore.getXPGiven() + " XP!\n");
            currentXP += ore.getXPGiven();
            Loader.console += ("Current XP: " + currentXP + " XP\n");
            Loader.console += ("Current Skill Level: " + skillLevel + "\n");
            Loader.console += "\n";
            invent.addToInventory(oreItemID);
            Loader.console += "\n\n";
        }
    }
}
//(skillLevel * 15) + (pick.getPickaxeLevel() * 100))
                   // * ore.getDifficulty() - pick.getPickaxeLevel() * 350;